package bepviet.android.ui;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import bepviet.android.engine.MainMenu;
import bepviet.android.engine.R;
import bepviet.android.engine.WebServiceAdapter;
import bepviet.android.properties.User;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class Login extends Activity{

	private TextView txtuser,txtpass;
	private Button btnLogin;
	private WebServiceAdapter serviceAdapter;
	private SoapObject responseBody = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		txtuser = (TextView)findViewById(R.id.txtuser);
		txtpass = (TextView)findViewById(R.id.txtpass);
		btnLogin = (Button)findViewById(R.id.btnlogin);
		serviceAdapter = new WebServiceAdapter("Login");
		btnLogin.setOnClickListener(new View.OnClickListener() {
		
			@Override
			public void onClick(View v) {
				String user_id = txtuser.getText().toString();
				String user_pass = txtpass.getText().toString();
				String temp = serviceAdapter.Login(user_id, user_pass);
				if(temp.equals("true")){
					startActivity(new Intent(Login.this,MainMenu.class));
					User user = new User( user_id );
				}
				else
					Toast.makeText(Login.this, "Fail", Toast.LENGTH_LONG).show();
			}
		});
	}
	
}
